import { defineStore } from 'pinia'
import { type RouteRecordRaw } from 'vue-router'

type RouteState = {
  /** 路由数组 */
  routes: Array<RouteRecordRaw>
}

export const useRoutesStore = defineStore('routes', {
  state: (): RouteState => ({
    routes: []
  }),
  getters: {

  },
  actions: {
    initRoutes() {
      // state.routes = baseRoutes
    },
    addRoutes(routes: Array<RouteRecordRaw> | RouteRecordRaw) {
      if (routes instanceof Array) {
        this.routes = this.routes.concat(routes)
      } else if (routes instanceof Object) {
        this.routes = this.routes.concat([routes])
      }
    }
  },
})